package com.print.graphics;
/**
 * 
* @ClassName: MainClass  
* @Description:测试java方法
* @author ZhengZengLiang  
* @date 2017年7月27日  
*
 */
public class MainClass {

	 public static void main(String[] args) {
       /* int nDisks = 10;
        doTowers(nDisks, 'A', 'B', 'C');*/
		 
		 /*for (int counter = 0; counter <= 15; counter++){
            System.out.printf("Fibonacci of %d is: %d\n",
            counter, fibonacci(counter));
        }*/
		 
		 for (int counter = 0; counter <= 10; counter++){
	        System.out.printf("%d! = %d\n", counter,
	        factorial(counter));
	    }
    }
	 
	 /**
	  * 
	 * @Title: doTowers  
	 * @Description: 汉若塔  
	 * @param @param topN
	 * @param @param from
	 * @param @param inter
	 * @param @param to    参数  
	 * @return void    返回类型  
	 * @throws
	  */
    public static void doTowers(int topN, char from, char inter, char to) {
        if (topN == 1){
            System.out.println("Disk 1 from "
            + from + " to " + to);
        }else {
            doTowers(topN - 1, from, to, inter);
            System.out.println("Disk "
            + topN + " from " + from + " to " + to);
            doTowers(topN - 1, inter, from, to);
        }
    }
    
    /**
     * 
    * @Title: fibonacci  
    * @Description: 斐波那契数列的实现  
    * @param @param number
    * @param @return    参数  
    * @return long    返回类型  
    * @throws
     */
    public static long fibonacci(long number) {
	    if ((number == 0) || (number == 1))
	        return number;
	    else
	        return fibonacci(number - 1) + fibonacci(number - 2);
	}
    
    /**
     * 
    * @Title: factorial  
    * @Description: 一个正整数的阶乘（英语：factorial）是所有小于及等于该数的正整数的积，并且有0的阶乘为1。
    * 自然数n的阶乘写作n!。亦即n!=1×2×3×...×n。阶乘亦可以递归方式定义：0!=1，n!=(n-1)!×n。 
    * @param @param number
    * @param @return    参数  
    * @return long    返回类型  
    * @throws
     */
    public static long factorial(long number) {
        if (number <= 1)
            return 1;
        else
            return number * factorial(number - 1);
    }

}
